package com.chenyongjing.design.pattern.iterator.general;

/**
 * @Author chen
 * @Date 2022/11/19 13:53
 */
public class Test {
    public static void main(String[] args) {
        // 来有一个容器对象
        IAggregate<String> aggregate = new ConcreteAggregate<String>();
        // 添加元素
        aggregate.add("one");
        aggregate.add("two");
        aggregate.add("three");
        // 获取容器爹地对象
        Iterator<String> iterator = aggregate.iterator();
        // 遍历
        while (iterator.hasNext()){
            String element = iterator.next();
            System.out.println(element);
            // 们没有设置游标只有移除当前元素
            aggregate.remove(element);
        }
    }
}
